﻿<!-- #Include File="../Include/Admin_Onlogin.asp" -->
<!-- #Include File="../../Include/WriteHtml.asp" -->
<%
Response.Write "<!DOCTYPE html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<title>生成栏目管理</title>" & vbCrlf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
Response.Write "<link rel=""stylesheet"" href=""../Style/global.css"" media=""all"">" & vbCrLf
Response.Write "<link rel=""stylesheet"" href=""../Style/font.css"" media=""all"">" & vbCrLf
Response.Write "<script type='text/javascript'>" & vbCrLf
Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
Response.Write "</script>" & vbCrLf
Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
Response.Write "</head>" & vbCrlf
Response.Write "<body>" & vbCrlf
Response.Write "<div class=""admin-main layui-anim layui-anim-upbit"">" & vbCrlf
If Not ChannelIsCreateHtml = True Then
	Response.Write "<script type='text/javascript'>Dialog.alert('对不起~！此模型不支持生成HTML功能。如果你要使用生成HTML功能，请在此模型管理中打开HTML生成功能！',function(){parent.tab.getdeleteTab();});</script>"
	Response.End()
End If

Server.ScriptTimeout = 99999
ChannelID = Code_ID("ChannelID")
If ChannelID = 0 Then ChannelID = 1
Call GetChannel(ChannelID)
Dim p,Ls,ChannelIndexUrl,ChannelIndexPath,IndexPath,ShowmPath,ListUrl,ListPath
Set Ls=New Cls_HTML

If Web_IsCreatIndex=True And Web_IsCreatIndexShow=True Then
	p=4
ElseIf Web_IsCreatIndex=True Or Web_IsCreatIndexShow=True Then
	p=3
Else
	p=2
End If
Response.Write("<div id=""prompt""><ul>")
progress_init
progress int(1/p*100),"读取模型首页数据,开始模型首页..."
ChannelIndexUrl = InstallDir & ChannelDir & "/Index.asp"
ChannelIndexPath = InstallDir & ChannelDir & "/Index" & ChannelHtmlExtName
HtmlContent = ShowChannelIndex(True)
WriteTOFile ChannelIndexPath,HtmlContent
HtmlContent = ""
progress int(2/p*100),"生成模型首页（HTML）完成,开始生成模型首页..."
If Web_IsCreatIndex=True Then
	IndexPath = InstallDir & Web_IndexFile
	HtmlContent = Html.SiteIndex(True)
	WriteTOFile IndexPath,HtmlContent
	HtmlContent = ""
	If Web_IsCreatIndexShow=True Then
		progress int(3/p*100),"生成网站导页（HTML）完成."
	Else
		progress int(p/p*100),"生成网站导页（HTML）完成."
	End If
End If
If Web_IsCreatIndexShow=True Then
	ShowmPath = InstallDir & Web_IndexShowFile
	HtmlContent = Html.SiteShow(True)
	WriteTOFile ShowmPath,HtmlContent
	HtmlContent = ""
	progress int(p/p*100),"生成网站首页（HTML）完成."
End If
If IsConn = False Then Call CloseConn()
Response.Write "<b>恭喜您！模型首页、网站导页、网站首页（HTML）生成完毕,请返回进行其它操作!</b><br>"
Response.Write "总费时<font color=""#FF0000"">" & FormatNumber((timer()-BeginTime), 2,-1) & "</font>秒,完成时间" & Now()
Response.Write("</ul></div>")
Response.Write "</div>" & vbCrlf
Response.Write "</body>" & vbCrLf & "</html>"
Call CloseConn()

Public Function ShowChannelIndex(IsHtml)
	Tit=ChannelName&"首页"
	Dim ListContent
	If ChannelMoban="" Then
		ChannelMoban = "Index.html"
	End If
	If ChannelSkinID="" Then
		ChannelSkinID = "DefaultSkin.css"
	End If
	HtmlContent = ChannelTemplate(ChannelMoban,ChannelSkinID,ChannelID)
	If Instr(HtmlContent,"【Repeat】") > 0 Then
	   lablez = "【Repeat】"
	Else
	   Exit Function
	End If
	regEx.Pattern = "【Repeat】([\s\S]*?)【\/Repeat】"
	Set Matches = regEx.Execute(HtmlContent)
	For Each Match In Matches
		Repeat = Match.SubMatches(0)
		HtmlContent = regEx.Replace(HtmlContent, "{$Repeat}")
		
		'得到每行显示的列数
		iCols = 1
		regEx.Pattern = "【Cols=(\d{1,2})】"
		Set Matches2 = regEx.Execute(Repeat)
		Repeat = regEx.Replace(Repeat,"")
		For Each Match2 In Matches2
			If Match2.SubMatches(0) > 1 Then iCols = Match2.SubMatches(0)
		Next
		Repeat2 = ""
		iClassID = 0
		Call Exec(rsClass,"select * from Class where ChannelID=" & ChannelID & " And ClassParent=0 Order By ClassOrder Asc,ClassID Asc",2)
		Do While Not rsClass.EOF
			ListContent = Repeat
			Cid=Int(rsClass("ClassID"))
			ClassName=rsClass("ClassName")
			If ChannelIsCreateHtml = True Then
				mores=InstallDir & ChannelDir & "/"&rsClass("HtmlFileDir")&"Index"&ChannelHtmlExtName
			Else
				mores=InstallDir & ChannelDir & "/List.asp?ClassID="&Cid
			End If
			ListContent = Replace(ListContent,"{$ClassID}",Cid)
			ListContent = Replace(ListContent,"{$ClassName}",ClassName)
			ListContent = Replace(ListContent,"{$more}",mores)
			rsClass.MoveNext
			iClassID = iClassID + 1
			If iClassID Mod iCols = 0 And Not rsClass.EOF Then
				Repeat2 = Repeat2 & ListContent
				If iCols > 1 Then Repeat2 = Repeat2 & "</tr><tr>"
			Else
				Repeat2 = Repeat2 & ListContent
				If iCols > 1 Then Repeat2 = Repeat2 & "<td width='5'></td>"
			End If
		Loop
		rsClass.Close
		Set rsClass = Nothing
		HtmlContent = Replace(HtmlContent, "{$Repeat}", Repeat2)
	Next
	HtmlContent = Replace(HtmlContent,"{$ClassID}",Cid)
	HtmlContent = Replace(HtmlContent,"{$ListNum}",CLng(ChannelListNum(0)))
	HtmlContent = Replace(HtmlContent,"{$CuteNum}",CLng(ChannelCuteNum(0)))
	HtmlContent = Replace(HtmlContent,"{$ChannelID}",ChannelID)
	HtmlContent = Replace(HtmlContent,"{$ChannelTit}",ChannelTit)
	HtmlContent = Replace(HtmlContent,"{$ChannelDir}",ChannelDir)
	HtmlContent = Replace(HtmlContent,"{$ChannelName}",ChannelName)
	HtmlContent = Replace(HtmlContent,"{$ChannelUnit}",ChannelUnit)
	HtmlContent = ReplaceHtml(HtmlContent)
	HtmlContent = Html.ReadClass(HtmlContent)
	HtmlContent = Html.ReadClassName(HtmlContent)
	HtmlContent = Html.ReadChannelList(HtmlContent)
	HtmlContent = Html.ReadChannelPic(HtmlContent)
	HtmlContent = Html.ReadChannelFlash(HtmlContent)
	HtmlContent = Html.ReadChannelFlashqq(HtmlContent)
	HtmlContent = ReHtml(HtmlContent)
	If IsHtml=True Then
		ShowChannelIndex = HtmlContent
	Else
		Response.Write HtmlContent
	End If
End Function
%>